﻿using System;

namespace Microsoft.WowAddonStudio.Lua.Parser
{
    public class ConsoleErrorHandler : IErrorHandler
    {
        private int errorCount, warningCount;

        public int ErrorCount
        {
            get { return errorCount; }
        }

        public int WarningCount
        {
            get { return warningCount; }
        }

        public void AddError(string message, int line, int column, int length, bool isWarning)
        {
            if (message == null)
                throw new ArgumentNullException("message");

            if (isWarning)
            {
                Console.WriteLine("{0}:{1}-{0}:{2}: {3}", line, column, column + length, message);
                warningCount++;
            }
            else
            {
                Console.Error.WriteLine("{0}:{1}-{0}:{2}: {3}", line, column, column + length, message);
                errorCount++;
            }
        }
    }
}
